<template>
  <div class="simple-table">
    <div class="header">
      <div v-for="(item) in columns" :key="item.name" class="header-item" :style="{flex:item.flex}">
        {{ item.title }}
      </div>
    </div>
    <div class="row-box" @scroll="$emit('nextPage',$event)">
      <div v-for="(row, rowIndex) in datas" :key="rowIndex" @click="$emit('itemClick',row)" class="row">
        <div v-for="(col) in columns" :key="col.name" class="row-item"
             :style="{flex:col.flex,color:col.name === 'typeName'?['','#fff','#FACE96','#ed5246'][row.type]:''}">
          {{ row[col.name] }}
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// eslint-disable-next-line no-undef
defineProps({
  columns: {
    type: Array,
    default: () => [],
  },
  datas: {
    type: Array,
    default: () => [],
  },
});
defineEmits(['nextPage','itemClick'])

</script>

<style lang="less" scoped>
@import "./index.less";
</style>
